package com.ylxn.elasticsearch;

import org.apache.http.HttpHost;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;

import java.io.IOException;

/**
 * @author: coll man
 * @create: 2021-05-17 09:49
 */
public class es_delete {
    public static void main(String[] args) throws IOException {
        RestHighLevelClient client = new RestHighLevelClient(
                RestClient.builder(new HttpHost("localhost",9200,"http"))
        );
        DeleteIndexRequest request = new DeleteIndexRequest("user233211");
        AcknowledgedResponse response = client.indices().delete(request, RequestOptions.DEFAULT);


        System.out.println("删除： = "+response.isAcknowledged());
        System.out.println(response);
        client.close();
    }
}
